const mysql = require('mysql2/promise');

async function testConnection() {
  try {
    console.log('测试连接参数: host=localhost, user=root, password=123456, port=3390');
    const connection = await mysql.createConnection({
      host: 'localhost',
      user: 'root',
      password: '123456',
      port: 3390
    });

    console.log('✅ 连接成功!');
    
    // 检查数据库
    const [databases] = await connection.execute('SHOW DATABASES');
    console.log('可用数据库:', databases.map(db => db.Database));
    
    await connection.end();
  } catch (error) {
    console.log('❌ 连接失败:', error.code, error.message);
  }
}

testConnection();
